//
//  SDPhotoPostionCell.m
//  SKinDiary
//
//  Created by pcyang on 16/7/16.
//  Copyright © 2016年 tencent. All rights reserved.
//

#import "SDPhotoPositionCell.h"
#import "SDPhotoTagView.h"

@interface SDPhotoPositionCell()<PhotoTagViewDelegate>

@end

@implementation SDPhotoPositionCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
    }
    return self;
}

-(void)initView
{
    [super initView];
    self.titleLabel.text = @"照片部位";
    [self.titleLabel sizeToFit];
}

-(void)initData
{
    self.tagItemsArray = [SDPhotoPositionCell getTagItems];
    self.tagViewsArray = [NSMutableArray arrayWithCapacity:self.tagItemsArray.count];
    for (PhotoTagItem* tagItem in self.tagItemsArray) {
        SDPhotoTagView* tagItemView = [SDPhotoTagView buttonWithType:UIButtonTypeCustom];
        tagItemView.delegate = self;
        [self.contentView addSubview:tagItemView];
        [tagItemView setTagItem:tagItem];
        [self.tagViewsArray addObject:tagItemView];
    }
}

+(NSMutableArray*)getTagItems
{
    NSMutableArray* tagItems = [NSMutableArray arrayWithCapacity:2];
    PhotoTagItem* tagItem1 = [[PhotoTagItem alloc] init];
    tagItem1.title = @"面部";
    
    PhotoTagItem* tagItem2 = [[PhotoTagItem alloc] init];
    tagItem2.title = @"颈部";
    
    PhotoTagItem* tagItem3 = [[PhotoTagItem alloc] init];
    tagItem3.title = @"手部";
    
    PhotoTagItem* tagItem4 = [[PhotoTagItem alloc] init];
    tagItem4.title = @"足部";
    
    PhotoTagItem* tagItem5 = [[PhotoTagItem alloc] init];
    tagItem5.title = @"头皮";
    
    [tagItems addObject:tagItem1];
    [tagItems addObject:tagItem2];
    [tagItems addObject:tagItem3];
    [tagItems addObject:tagItem4];
    [tagItems addObject:tagItem5];
    return tagItems;
}

#pragma  mark -PhotoTagViewDelegate
-(void)tagViewPressed:(SDPhotoTagView*)addTagView
{
    for (SDPhotoTagView* tagItemView in self.tagViewsArray) {
        PhotoTagItem* tagItem  = [tagItemView getTagItem];
        if (![addTagView isEqual:tagItemView]) {
            tagItem.inUsed = NO;
        }
        [tagItemView refresh];
    }
}

@end
